// **************************************************************************
// *  File: ajax.js
// *  (c) MGS aplications 2009-2011
// *  By elwizard. All rights reserved.
// *  http://www.desarrollo-mkportal.org
// *
// *  This program is free software under MGS License Agreement. 
// *  You cannot distribute in any way. For modifications, please read 
// *  MGS License Agreement for more information.
// *
// **************************************************************************


function do_AJAX(lurl, str, divContainer) {
 
  var myurl = lurl;  
  var mydiv = divContainer;
  
  //document.getElementById(mydiv).innerHTML="<img src='images/site/loading3.gif' alt='' border='0' width='11' height='11' />";
  
  if (str.length==0) { 
    document.getElementById(mydiv).innerHTML="";
    return;
  }
    
  xmlHttp = GetXmlHttpObject();
  if (xmlHttp==null) {
    alert ("Your browser does not support AJAX!");
    return;
  }
    
  myurl=myurl+"&q="+str;
  
  xmlHttp.onreadystatechange=function(xmlHttp, mydiv) {
  	return function() {
  		
  		if (xmlHttp.readyState==4) {
        if (xmlHttp.status==200) {

          document.getElementById(mydiv).innerHTML = xmlHttp.responseText;
          
        }
      }
  		
  };
  } (xmlHttp, mydiv);
  
  xmlHttp.open("GET",myurl,true);
  xmlHttp.send(null);

}

function GetXmlHttpObject() {
var xmlHttp=null;
try {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e) {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}
